// Event.cpp: implementation of the Event class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "kwservercore.h"
#include "Event.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Event::Event()
{
}

Event::~Event()
{
}

int Event::InsertToListCtrl(CListCtrl& listctrl) const
{
	LVITEM curListItem;

	curListItem.mask = LVIF_TEXT | LVIF_PARAM;
	curListItem.iItem = 0;
	curListItem.iSubItem=0;
	CString str;
	str = m_time.Format("%Y.%m.%d %H:%M:%S");
	curListItem.pszText = str.LockBuffer();
	curListItem.cchTextMax = lstrlen(curListItem.pszText);
	curListItem.lParam = (LPARAM)this;
	int iActualItem = listctrl.InsertItem(&curListItem);
	str.UnlockBuffer();

	curListItem.mask = LVIF_TEXT;
	curListItem.iItem = iActualItem;
	curListItem.iSubItem = 1;
	str = m_strUserId;
	curListItem.pszText = str.LockBuffer();
	curListItem.cchTextMax = lstrlen(curListItem.pszText);
	listctrl.SetItem(&curListItem);
	str.UnlockBuffer();

	curListItem.iSubItem = 2;
	str = m_strIPAddr;
	curListItem.pszText = str.LockBuffer();
	curListItem.cchTextMax = lstrlen(curListItem.pszText);
	listctrl.SetItem(&curListItem);
	str.UnlockBuffer();

	curListItem.iSubItem = 3;
	str = m_strDescription;
	curListItem.pszText = str.LockBuffer();
	curListItem.cchTextMax = lstrlen(curListItem.pszText);
	listctrl.SetItem(&curListItem);
	str.UnlockBuffer();

	listctrl.SetItemState(iActualItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);

	return iActualItem;
}